// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>
#include <windows.h>
// FROM: http://stackoverflow.com/questions/509989/how-to-allow-32-bit-apps-on-64-bit-windows-to-execute-64-bit-apps-provided-in-wi
class Wow64RedirectOff {
    typedef BOOL (WINAPI *FN_Wow64DisableWow64FsRedirection) ( __out PVOID *OldValue );
    typedef BOOL (WINAPI *FN_Wow64RevertWow64FsRedirection) ( __in  PVOID OldValue );

public:
    Wow64RedirectOff() {
    	LPFN_Disable = (FN_Wow64DisableWow64FsRedirection)GetProcAddress(
    		GetModuleHandle(TEXT("kernel32")),"Wow64DisableWow64FsRedirection");
    	if( LPFN_Disable ) {
    		LPFN_Disable(&OldValue);
    	}
    }

    ~Wow64RedirectOff() {
    	if( LPFN_Disable ) {
    		FN_Wow64RevertWow64FsRedirection LPFN_Revert = (FN_Wow64RevertWow64FsRedirection)GetProcAddress(
    			GetModuleHandle(TEXT("kernel32")),"Wow64RevertWow64FsRedirection");
    		if( LPFN_Revert ) {
    			LPFN_Revert(OldValue);
    		}
    	}
    }

private:
    FN_Wow64DisableWow64FsRedirection LPFN_Disable;
    PVOID OldValue;	
};

// TODO: reference additional headers your program requires here
